package com.xuecheng.content.convert;

import com.xuecheng.api.content.model.dto.CourseBaseDTO;
import com.xuecheng.api.content.model.vo.CourseAuditVO;
import com.xuecheng.api.content.model.vo.CourseBaseVO;
import com.xuecheng.content.entity.CourseBase;
import com.xuecheng.content.entity.CoursePub;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface CourseBaseConvert {

    CourseBaseConvert INSTANCE = Mappers.getMapper(CourseBaseConvert.class);

    /**
     * @param courseBase 源对象
     * @return 转换后的对象
     * @Mapping 映射的是不能转换的属性
     */
    @Mapping(source = "id", target = "courseBaseId")
    CourseBaseDTO entity2dto(CourseBase courseBase);

    /**
     * @param courseBaseDTO 源对象
     * @return 转换后的对象
     * @Mapping 映射的是不能转换的属性
     */
    @Mapping(source = "courseBaseId", target = "id")
    CourseBase dto2entity(CourseBaseDTO courseBaseDTO);

    /**
     * @param courseBaseVO 源对象
     * @return 转换后的对象
     */
    CourseBaseDTO vo2dto(CourseBaseVO courseBaseVO);


    /**
     * @param courseAuditVO 源对象
     * @return 转换后的对象
     */
    CourseBaseDTO vo2dto(CourseAuditVO courseAuditVO);

    /**
     * 集合转换
     *
     * @param list
     * @return
     */
    List<CourseBaseDTO> entitys2dtos(List<CourseBase> list);

    /**
     * @param courseBase 源对象
     * @return 转换后的对象
     * @Mapping 映射的是不能转换的属性
     */
    @Mapping(source = "id", target = "courseId")
    CoursePub entity2entity(CourseBase courseBase);

}
